package com.xiaoran.RMQ_1.test3;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.MessageProperties;
import com.xiaoran.RMQ_1.utlis.RabbitMqUtils;

import java.util.Scanner;

public class ACK_Produce {
    public static final  String QUEUE_NAME="ack_queue";
    public static void main(String args[]) throws Exception{
        Channel channel= RabbitMqUtils.getChannel();
        //创建队列
        channel.queueDeclare(QUEUE_NAME,true,false,false,null);
        //从控制台中输入信息
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNext()){
           String message=scanner.next();
           //发送消息
           channel.basicPublish("",QUEUE_NAME,MessageProperties.PERSISTENT_TEXT_PLAIN,message.getBytes());
           System.out.println("生产者发送的消息是: "+message);
        }

    }
}

